<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('站内邮箱列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 80px !important;">标题&nbsp;&nbsp;</label>
                                <input style="width: 150px !important;" type="text" name="biaoti"/>
                            </li>
                            <li class="sousuo">
                                <a class="btn btn-success btn-md" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-md" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-md" id="toolbar" role="group">
                <button class="btn btn-danger btn-md dim multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:xiaoxi:saveBoxremove">
                    <i class="fa fa-download"></i> 删除
                </button>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:xiaoxi:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:xiaoxi:saveBoxremove')}]];
        var zhuangtaiDatas = [[${@dict.getType('sys_xiaoxi_status')}]];
        var prefix = ctx + "system/xiaoxi";
        function bootstrapTableFieldCellStyle() {
            return {
                css: {
                    "max-width": "200px" ,
                    "white-space": "nowrap" ,
                    "text-overflow": "ellipsis" ,
                    "overflow": "hidden" ,
                }
            };
        }
        function openEdit(id) {
            $.modal.openOptions({
                url:prefix + "/edit/"+id,
                title:"草稿箱",
                btn:['<i class="fa fa-check"></i> 发送邮件', '<i class="fa fa-save"></i> 保存草稿'],
                yes: function(index, layero) {
                    //点击第一个按钮处理逻辑
                    layero.find("iframe")[0].contentWindow.submit(1)
                    layer.close(index);
                },
                btn2: function(index, layero){
                    //点击第二个按钮处理逻辑
                    layero.find("iframe")[0].contentWindow.submit(0)
                    layer.close(index);
                },

            });
        }
        $(function() {

            var options = {
                url: prefix + "/saveBoxlist",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/SaveBoxremove",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "草稿箱",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'xiaoxiid',
                    title: 'xiaoxiid',
                    visible: false
                },
                {
                    field: 'biaoti',
                    title: '邮件标题'
                },
                {
                    field: 'neirong',
                    title: '邮件内容',
                    formatter: function(value, row, index) {
                        if(value.length>200)return value.substr(0, 200) + "...";
                        return value
                    }
                },
                {
                    field: 'jieshouren',
                    title: '接收人',
                    cellStyle: bootstrapTableFieldCellStyle,
                },
                {
                    title: '操作',
                    align: 'center',
                    width:200,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-md ' + editFlag + '" href="javascript:void(0)" onclick="openEdit(\'' + row.xiaoxiid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-md ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.xiaoxiid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>